// import sdk from './sdk.js';
// import expand from './expand.js';
// import jquery_expand from './jquery_expand.js';
// import Swiper from './swiper-bundle.esm.browser.min.js';
// import component from './component.js';
// import axios from "axios"
// import 'bootstrap'
// import 'bootstrap/dist/css/bootstrap.min.css'
// import 'quill/dist/quill.core.css' // import styles
// import 'quill/dist/quill.snow.css' // for snow theme
// import 'quill/dist/quill.bubble.css' // for bubble theme
// import VueQuillEditor from 'vue-quill-editor'

// import {
// 	BootstrapVue,
// 	IconsPlugin
// } from 'bootstrap-vue'

/**
 * 检测图片是否存在
 * @param url
 */
let imageIsExist = function (url) {
	return new Promise((resolve) => {
		var img = new Image();
		img.onload = function () {
			if (this.complete == true) {
				resolve(true);
				img = null;
			}
		}
		img.onerror = function () {
			resolve(false);
			img = null;
		}
		img.src = url;
	})
}

const globalDirective={

	install: function (app) {
		/**
		 * 指令名称为：default-img
		 * @param {Object} el
		 * @param {Object} binding
		 */
		 app.directive('default-img', {
			mounted(el, binding, vnode) {
				let imgURL = binding.value; //获取图片地址
				if (imgURL) {
					let exist = imageIsExist(imgURL);
					if (exist) {
						el.onerror = function () {
							el.setAttribute('src', imgURL);
						}
					}
				}
			 },
			
		});
		

		// Vue.use(BootstrapVue);
		// Vue.use(IconsPlugin);
		// Vue.prototype.$Swiper = Swiper
		// Vue.prototype.$axios = axios
		// Vue.use(component, options);
		// Vue.use(VueQuillEditor, options)

	}
}


export default globalDirective